<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="tutorial.css">
<TITLE>
Same Problem - Different Model
</TITLE>
</HEAD>
<BODY >
<A HREF="tutorial082.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="tutorial079.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="tutorial084.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc154">11.4</A>&nbsp;&nbsp;Same Problem - Different Model</H2>

There are often many ways of modelling a problem.
Consider the famous "SEND + MORE = MONEY" example:

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
sendmore(Digits) :-
    Digits = [S,E,N,D,M,O,R,Y],
    Digits :: [0..9],
    alldifferent(Digits),
    S #<CODE>\</CODE>= 0, M #<CODE>\</CODE>= 0,
                 1000*S + 100*E + 10*N + D
               + 1000*M + 100*O + 10*R + E
    #= 10000*M + 1000*O + 100*N + 10*E + Y.
</PRE></BLOCKQUOTE></TD>
</TR></TABLE>
An alternative model is based on the classical decimal addition algorithm with
carries:

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
sendmore(Digits) :-
    Digits = [S,E,N,D,M,O,R,Y],
    Digits :: [0..9],
    Carries = [C1,C2,C3,C4],
    Carries :: [0..1],
    alldifferent(Digits),
    S #<CODE>\</CODE>= 0,
    M #<CODE>\</CODE>= 0,
    C1         #= M,
    C2 + S + M #= O + 10*C1,
    C3 + E + O #= N + 10*C2,
    C4 + N + R #= E + 10*C3,
         D + E #= Y + 10*C4.
</PRE></BLOCKQUOTE></TD>
</TR></TABLE>
Both models work fine, but obviously involve different variables and
constraints. Even though high-level models reduce the need for finding
sophisticated encodings of problems, finding good models still requires
substantial expertise and experience.<BR>
<BR>
<HR>
<A HREF="tutorial082.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="tutorial079.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="tutorial084.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
